import matplotlib.pyplot as plt
import pandas as pd
from datetime import datetime

plt.rcParams['font.sans-serif'] = ['Microsoft YaHei']  # 指定默认字体：解决plot不能显示中文问题
plt.rcParams['axes.unicode_minus'] = False

data = pd.read_csv("./data/content.csv")
time = data['发送时间']
time = time.apply(lambda x: datetime.fromtimestamp(x).strftime("%H"))
time = time.value_counts()
x = time.index.to_list()
print(x)

# 设置图框的大小
fig3 = plt.figure(figsize=(10, 6))
plt.title("《夺冠》根据时间分析评论数量")
plt.xlabel("时间")
plt.ylabel("评论数量")

plt.plot(x, time, linestyle='--', linewidth=2, color='green', marker='*', markersize=8, markeredgecolor='black',
         markerfacecolor='yellow')  # 点的填充色

fig3.autofmt_xdate(rotation=45)

plt.show()
